//
//  WNEmptyView.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/4.
//

import UIKit
import LYEmptyView
import Foundation

enum EmptyDesc: String {
    case netWork = "Network error, please check your network"
    case serverBad = "Page exception, please refresh the page"
    case common = "There is nothing here"
    case none = ""

    case discover = "Sorry!\nNo book."
    case recommend = "Coming soon!\nMore good books."
    case library = "You have not added any books\nto your Library yet."
    case rank = "Sorry!\nLeaderboard has no data."
    case comment = "Share your reading experience with us."
    case search = "Sorry!\nNo resources available."
    case history = "You haven't viewed any books yet.\nGo and explore Books!"
    case record = "You haven't received an award yet"
    case inbox = "No Message"
}

enum EmptyImage: String {
    case netWork = "empty_netWork"
    case serverBad = "empty_serverBad"
    case common = "empty_common"
    case none = ""

    case discover = "empty_discover"
    case recommend = "empty_recommend"
    case library = "empty_library"
    case comment = "empty_comment"
    case inbox = "empty_inbox"
}

class WNEmptyView: LYEmptyView {
    
    var btnStr = "" {
        didSet {
            actionBtnFont = .wn_font(name: .bold, size: 15)
            actionBtnTitleColor = .white
            actionBtnBackGroundColor = .init(named: "red_FE95B4")
            actionBtnMargin = 32
            actionBtnWidth = 120
            actionBtnHeight = 36
            actionBtnCornerRadius = 18
            btnTitleStr = btnStr
        }
    }

    /// 文本 + 按钮
    class func wn_loadStyle(descStr: EmptyDesc = .none, imageStr: EmptyImage = .none, btnStr: String = "Click Refresh", _ contentViewY: CGFloat = UIResponder().scaleWidth(163), _ btnFrame: CGSize = CGSize(width: 160, height: 170), tapBlock: @escaping (()->())) -> LYEmptyView {
        let ev = WNEmptyView.emptyActionView(withImageStr: imageStr.rawValue, titleStr: "", detailStr: descStr.rawValue, btnTitleStr: btnStr, btnClick: tapBlock)
        ev?.contentViewY = contentViewY
        ev?.titleLabTextColor = .gray
        ev?.titleLabFont = .wn_font(name: .bold, size: 17)
        ev?.detailLabMaxLines = 3
        ev?.detailLabTextColor = .gray
        ev?.detailLabFont = .wn_font(name: .bold, size: 16)
        ev?.imageSize = btnFrame
        ev?.subViewMargin = 16
        if btnStr.count != 0 {
            ev?.actionBtnFont = .wn_font(name: .bold, size: 15)
            ev?.actionBtnTitleColor = .init(named: "red_FE95B4")
            ev?.actionBtnBackGroundColor = .white
            ev?.actionBtnMargin = 24
            ev?.actionBtnHeight = 44
            ev?.actionBtnWidth = 200
            ev?.actionBtnBorderWidth = 1
            ev?.actionBtnBorderColor = .init(named: "red_FE95B4")
            ev?.actionBtnCornerRadius = 22
        }
        return ev!
    }
}
